package mapData;

public class Obstruction 
{
    private int topX;
    private int topY;
    private int width;
    private int height;
    
    public Obstruction(int x, int y, int w, int h)
    {
        topX = x;
        topY = y;
        width = w;
        height = h;
    }
    
    public int getX()
    {
        return topX;
    }
    
    public int getY()
    {
        return topY;
    }
    
    public int getWidth()
    {
        return width;
    }
    
    public int getHeight()
    {
        return height;
    }
    
    public boolean isOnBound(Coord pos)
        //checks if Coord pos is on the bounds of an obstruction rectangle
    {
        int x = pos.getX();
        int y = pos.getY();
        
        if(y == topY && x >= topX && x < topX+width) //top bound
            return true;
        else if(y == (topY + height-1) && x >= topX && x < topX+width) //bottom bound
            return true;
        else if(x == topX && y >= topY && y < topY +height) //left bound
            return true;
        else if(x == (topX + width -1 ) && y >= topY && y < topY +height) // right bound
            return true;
        else
            return false;
    }
    
}